package com.lanchetech.admin.controller;

import com.lanchetech.admin.aop.OperatorLog;
import com.lanchetech.admin.service.AdvancePaymentService;
import com.lanchetech.bean.request.GoodsCardReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.AgreementSigningReq;
import com.lanchetech.bean.vo.AgreementSigningVo;
import com.lanchetech.entity.AgreementSigning;
import com.lanchetech.entity.GoodsCard;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "预付货款管理", tags = "预付货款管理")
@RequestMapping("/api/advance/payment")
@RestController
public class AdvancePaymentController {

    @Autowired
    AdvancePaymentService advancePaymentService;

    @ApiOperation(value = "获取卡列表", notes = "筛选条件 name,status")
    @GetMapping("/getGoodsCardList")
    public ResultData<BasePageResp<GoodsCard>> getGoodsCardList(@RequestBody GoodsCardReq req) {
        return advancePaymentService.getGoodsCardList(req);
    }

    @ApiOperation(value = "创建或编辑卡信息")
    @OperatorLog("创建或编辑卡信息")
    @PostMapping("/editGoodsCard")
    public BaseResp editGoodsCard(@RequestBody GoodsCard goodsCard) {
        return advancePaymentService.editGoodsCard(goodsCard);
    }

    @ApiOperation(value = "删除卡信息")
    @OperatorLog("删除卡信息")
    @PostMapping("/deletedCard")
    public BaseResp deletedCard(@RequestParam Long id) {
        return advancePaymentService.deletedCard(id);
    }

    @ApiOperation(value = "协议申请列表")
    @GetMapping("/agreementList")
    public ResultData<BasePageResp<AgreementSigningVo>> agreementList(@RequestBody AgreementSigningReq agreementSigningReq) {
        return advancePaymentService.agreementList(agreementSigningReq);
    }

    @ApiOperation(value = "商家/门店 协议申请/修改")
    @OperatorLog("商家/门店 协议申请")
    @PostMapping("apply")
    public BaseResp apply(@RequestBody AgreementSigning agreementSigning) {
        return advancePaymentService.apply(agreementSigning);
    }

    @PostMapping("examine")
    @ApiOperation("审核 同意/拒绝")
    @OperatorLog("审核 同意/拒绝")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "协议ID", paramType = "query", dataType = "Long"),
            @ApiImplicitParam(name = "status", value = "审核状态(1:审核中,2:审核成功," + "3:审核失败)", paramType = "query", dataType = "Byte"),
            @ApiImplicitParam(name = "reason", value = "拒绝原因", paramType = "query", dataType = "String")
    })
    public BaseResp examine(@RequestParam(value = "id") Long id,
                            @RequestParam(value = "status") Byte status,
                            @RequestParam(value = "reason", required = false) String reason) {
        return advancePaymentService.examine(id, status, reason);
    }

    @DeleteMapping("/delete/agreement")
    @ApiOperation("删除协议")
    @OperatorLog("删除协议")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "协议ID", paramType = "query", dataType = "Long")
    })
    public BaseResp deleteAgreement(@RequestParam(value = "id") Long id) {
        return advancePaymentService.deleteAgreement(id);
    }

    @DeleteMapping("/pull/blacklist")
    @ApiOperation("拉入黑名单")
    @OperatorLog("拉入黑名单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "协议ID", paramType = "query", dataType = "Long")
    })
    public BaseResp pullBlacklist(@RequestParam(value = "id") Long id) {
//        return advancePaymentService.pullBlacklist(id);
        return null;
    }
}

